package controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.BingValues;
import model.DEchartBingData;
import model.VClassCheckReport;
import model.VClassEPQCheckReportStatis;
import model.VClassMHTCheckReportStatis;
import model.VGradeCheckRport;
import model.VGradeEPQCheckReportStatis;
import model.VGradeMHTCheckReportStatis;
import model.VSchoolCheckReport;
import model.VSchoolEPQCheckReportStatis;
import model.VSchoolMHTCheckReportStatis;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import annotation.Log;

import com.alibaba.fastjson.JSON;

import persistent.factory.DAOFactory;
import util.toolkit.Constant;
import util.toolkit.Expression;
import util.toolkit.NumberUtil;
//import util.toolkit.ResponseJSON;

/**
 * 测评结果分析管理
 * @author djf
 * @since 2018/11/8
 */

@Controller
@RequestMapping(value = "/sysevaluationresult")
public class SysEvaluationResultController {

	/**
	 * 班级测评统计分析报告查看控制类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 班级测评统计分析报告查看控制类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询班级测评统计分析报告", operationClassPath = "controller.SysEvaluationResultController.getClassEvalAnalysis(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/班级测评统计分析报告")
	@RequestMapping(value = "/getclassevalanalysis")
	public String getClassEvalAnalysis(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression exp = new Expression();

		try {
			String reporttype = req.getParameter("reporttype");
			String checktime = req.getParameter("checktime");
			String gradename = req.getParameter("gradename");
			String classid = req.getParameter("classid");
			String schoolid = req.getParameter("schoolid");

			String currentPage = req.getParameter("page");
			String pageSize = req.getParameter("limit");

			if (currentPage != null && pageSize != null) {
				if (schoolid != null && !schoolid.equals("")) {
					exp.andEqu("schoolid", schoolid, String.class); // 添加schoolid的查询条件
				}
				if (reporttype != null && !reporttype.equals("")) {
					exp.andLike("checkname", reporttype, String.class);
				}
				if (gradename != null && !gradename.equals("")) {
					exp.andLike("totalclassname", gradename, String.class);
				}
				if (classid != null && !classid.equals("") && !classid.equals("null")) {
					exp.andEqu("classid", classid, String.class); // 添加classid的查询条件
				}
				if (checktime != null && !checktime.equals("")) {
					String[] checktimes = checktime.split("/");
					String starttime = checktimes[0];
					String endtime = checktimes[1];
					exp.andBetween("checktime", starttime, String.class);
					exp.andAnd(endtime, String.class);
				}
				exp.orderByAsc("checktime");

				String strwhere = exp.toString();
				List<VClassCheckReport> listsize = DAOFactory.getCheckReportDAO()
						.getClassCheckReportsByCondition(strwhere);
				List<VClassCheckReport> reportList = DAOFactory.getCheckReportDAO().getClassCheckReportsByCondition(
						strwhere, Integer.parseInt(currentPage), Integer.parseInt(pageSize));
				if (reportList != null && reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "班级统计测评分析报告查询成功");
					result.put("count", listsize.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			} else {
				result.put("code", 1);
				result.put("msg", "无查询结果");
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "班级统计测评分析报告查询失败");
		}

		PrintWriter write = resp.getWriter();
		write.print(result);
		return null;
	}

	/**
	 * 班级测评统计分析报告，MHT维度分析，表格数据
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author djf
	 */
	// TODO 班级测评统计分析报告，MHT维度分析，表格数据
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询班级测评统计分析报告，MHT维度分析表格数据", operationClassPath = "controller.SysEvaluationResultController.getClassCheckStatisByItem(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/班级测评统计分析报告")
	@RequestMapping(value = "/getclasscheckstatisbyitem")
	public String getClassCheckStatisByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression expression = new Expression();
		PrintWriter out = resp.getWriter();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String classid = req.getParameter("classid");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("")) {
				expression.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (classid != null && !classid.equals("")) {
				expression.andEqu("classid", classid, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) { // 测试类型为EPQ
					List<VClassEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVClassEPQCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {
						result.put("code", 0);
						result.put("msg", "查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}
					out.println(result);
					return null;
				} else { // 测试类型为MHT
					List<VClassMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVClassMHTCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {
						result.put("code", 0);
						result.put("msg", "查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}
					out.println(result);
					return null;
				}
			} else {
				result.put("code", 1);
				result.put("msg", "无查询结果");
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 1);
			result.put("msg", "班级测评分析报告查询失败");
		}
		return null;
	}

	/**
	 * 班级测评统计分析报告，MHT维度分析，饼图表
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 班级测评统计分析报告，MHT维度分析，饼图表
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询班级测评统计分析报告，MHT维度分析饼图表数据", operationClassPath = "controller.SysEvaluationResultController.getCheckStatisByItem(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/班级测评统计分析报告")
	@RequestMapping(value = "/getcheckstatisbyitem")
	public String getCheckStatisByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression exp = new Expression();

		String checktypeid = req.getParameter("checktypeid");
		String itemname = req.getParameter("itemname");
		String classid = req.getParameter("classid");
		String checktime = req.getParameter("checktime");

		try {
			if (checktypeid != null && !checktypeid.equals("")) {
				exp.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				exp.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (classid != null && !classid.equals("")) {
				exp.andEqu("classid", classid, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				exp.andEqu("checktime", checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) {
					List<VClassEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVClassEPQCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VClassEPQCheckReportStatis obj = (VClassEPQCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					out.close();
					return null;
				} else {
					List<VClassMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVClassMHTCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VClassMHTCheckReportStatis obj = (VClassMHTCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					return null;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	/**
	 * 班级EPQ维度分析报告表格加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @size 2018-11-09 22:07
	 * @author 徐震霖
	 */
	// TODO 班级EPQ维度分析报告表格加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询班级EPQ维度分析报告表格数据", operationClassPath = "controller.SysEvaluationResultController.getClassEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/班级测评统计分析报告")
	@RequestMapping(value = "/getclassepqstatistable")
	public String getClassEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression expression = new Expression();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String classid = req.getParameter("classid");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
				expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (classid != null && !classid.equals("") && !classid.equals("0")) {
				expression.andEqu("classid", classid, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}
			if (checktypeid.equals("1")) {
				List<VClassEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVClassEPQCheckReportStatisByCondition(expression.toString());
				if (reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "班级EPQ维度分析查询成功");
					result.put("count", reportList.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			} else {
				List<VClassMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVClassMHTCheckReportStatisByCondition(expression.toString());
				if (reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "班级EPQ维度分析查询成功");
					result.put("count", reportList.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "班级EPQ维度分析查询失败");
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;

	}

	/**
	 * 班级EPQ维度分析报告图表加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 班级EPQ维度分析报告图表加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询班级EPQ维度分析报告图表数据", operationClassPath = "controller.SysEvaluationResultController.getClassEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/班级测评统计分析报告")
	@RequestMapping(value = "/getclassepqstatischart")
	public String getClassEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression expression = new Expression();
		JSONObject result = new JSONObject();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String classid = req.getParameter("classid");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
				expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (classid != null && !classid.equals("") && !classid.equals("0")) {
				expression.andEqu("classid", classid, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid.equals("1")) {
				List<VClassEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVClassEPQCheckReportStatisByCondition(expression.toString());

				// 用于柱状图数据存储的实体类
				// DEchartBingData edata = new DEchartBingData();

				// 构建柱状图数据
				List<String> categories = new ArrayList<String>();
				List<BingValues> values = new ArrayList<BingValues>();

				for (int i = 0; i < reportList.size(); i++) {
					VClassEPQCheckReportStatis obj = (VClassEPQCheckReportStatis) reportList.get(i);
					String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
							+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
					categories.add(catename);
					BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
					values.add(bingValues);
				}
				// 添加饼状图中分类的数据列表
				// edata.setCategories(categories);
				// 添加柱状图中分类数值的数据列表
				// edata.setValues(values);

				JSONArray jsonArray1 = JSONArray.fromObject(categories);
				result.put("categories", jsonArray1);
				JSONArray jsonArray2 = JSONArray.fromObject(values);
				result.put("values", jsonArray2);

			} else {
				// System.out.println(expression.toString());
				List<VClassMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVClassMHTCheckReportStatisByCondition(expression.toString());

				// 用于柱状图数据存储的实体类
				// DEchartBingData edata = new DEchartBingData();

				// 构建柱状图数据
				List<String> categories = new ArrayList<String>();
				List<BingValues> values = new ArrayList<BingValues>();

				for (int i = 0; i < reportList.size(); i++) {
					VClassMHTCheckReportStatis obj = (VClassMHTCheckReportStatis) reportList.get(i);
					String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
							+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
					categories.add(catename);
					BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
					values.add(bingValues);
				}
				// 添加饼状图中分类的数据列表
				// edata.setCategories(categories);
				// 添加柱状图中分类数值的数据列表
				// edata.setValues(values);
				JSONArray jsonArray1 = JSONArray.fromObject(categories);
				result.put("categories", jsonArray1);
				JSONArray jsonArray2 = JSONArray.fromObject(values);
				result.put("values", jsonArray2);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}

	// TODO 2018-11-09 19:56 基于年级
	/**
	 * 年级测评统计分析报告查询控制类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author djf
	 */
	// TODO 年级测评统计分析报告查询控制类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级测评统计分析报告", operationClassPath = "controller.SysEvaluationResultController.getGradeEvaResultDetail(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgradeevaresult")
	public String getGradeEvaResultDetail(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression exp = new Expression();

		try {
			String reporttype = req.getParameter("reporttype");
			String checktime = req.getParameter("checktime");
			String gradename = req.getParameter("gradename");
			String schoolid = req.getParameter("schoolid");

			String currentPage = req.getParameter("page");
			String pageSize = req.getParameter("limit");

			if (currentPage != null && pageSize != null) {
				if (schoolid != null && !schoolid.equals("")) {
					exp.andEqu("schoolid", schoolid, String.class); // 添加schoolid的查询条件
				}
				if (reporttype != null && !reporttype.equals("")) {
					exp.andLike("checkname", reporttype, String.class);
				}
				if (gradename != null && !gradename.equals("")) {
					exp.andLike("gradename", gradename, String.class);
				}
				if (checktime != null && !checktime.equals("")) {
					String[] checktimes = checktime.split("/");
					String starttime = checktimes[0];
					String endtime = checktimes[1];
					exp.andBetween("checktime", starttime, String.class);
					exp.andAnd(endtime, String.class);
				}

				exp.orderByAsc("checktime");

				String strwhere = exp.toString();
				List<VGradeCheckRport> listsize = DAOFactory.getCheckReportDAO().getGradeCheckRportByStrwhere(strwhere);
				List<VGradeCheckRport> reportList = DAOFactory.getCheckReportDAO().getGradeCheckRportByStrwhere(
						strwhere, Integer.parseInt(currentPage), Integer.parseInt(pageSize));
				if (reportList != null && reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "年级测评统计分析报告查询成功");
					result.put("count", listsize.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			} else {
				result.put("code", 1);
				result.put("msg", "无查询结果");
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "年级测评统计分析报告查询失败");
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}

	/**
	 * 年级测评统计分析报告，MHT维度分析，表格数据
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author djf
	 */
	// TODO 年级测评统计分析报告，MHT维度分析，表格数据
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级测评统计分析报告，MHT维度分析表格数据", operationClassPath = "controller.SysEvaluationResultController.getGradeCheckStatisByItem(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgradecheckstatisbyitem")
	public String getGradeCheckStatisByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression expression = new Expression();
		PrintWriter out = resp.getWriter();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String gradename = req.getParameter("gradename");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("")) {
				expression.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (gradename != null && !gradename.equals("")) {
				expression.andEqu("gradename", gradename, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) {
					List<VGradeMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVGradeMHTCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {
						result.put("code", 0);
						result.put("msg", "查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}

					out.println(result);
					return null;
				} else {
					List<VGradeMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVGradeMHTCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {

						result.put("code", 0);
						result.put("msg", "查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}
					out.println(result);
					return null;
				}
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "年级测评统计分析报告MHT查询失败");
		}
		return null;
	}

	/**
	 * 年级测评统计分析报告，MHT维度分析，饼图表
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 年级测评统计分析报告，MHT维度分析，饼图表
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级测评统计分析报告，MHT维度分析饼图数据", operationClassPath = "controller.SysEvaluationResultController.getGradeCheckStatisByItemBing(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgradecheckstatisbyitembing")
	public String getGradeCheckStatisByItemBing(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression exp = new Expression();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String gradename = req.getParameter("gradename");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("")) {
				exp.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				exp.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (gradename != null && !gradename.equals("")) {
				exp.andEqu("gradename", gradename, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				exp.andEqu("checktime", checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) {
					List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVGradeEPQCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VGradeEPQCheckReportStatis obj = (VGradeEPQCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					out.close();
					return null;
				} else {
					List<VGradeMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVGradeMHTCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VGradeMHTCheckReportStatis obj = (VGradeMHTCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					return null;
				}
			} else {

			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	/**
	 * 年级EPQ维度分析报告表格加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @size 2018-11-09 22:07
	 * @author 徐震霖
	 */
	// TODO 年级EPQ维度分析报告表格加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级EPQ维度分析报告表格数据", operationClassPath = "controller.SysEvaluationResultController.getGradeEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgradeepqstatistable")
	public String getGradeEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression expression = new Expression();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String gradeName = req.getParameter("gradename");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
				expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (gradeName != null && !gradeName.equals("")) {
				expression.andEqu("gradename", gradeName, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}
			if (checktypeid.equals("1")) {
				List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVGradeEPQCheckReportStatisByCondition(expression.toString());
				if (reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "年级EPQ维度分析报告查询成功");
					result.put("count", reportList.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			} else {
				List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVGradeEPQCheckReportStatisByCondition(expression.toString());
				if (reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "年级EPQ维度分析报告查询成功");
					result.put("count", reportList.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "年级EPQ维度分析报告查询失败");
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;

	}

	/**
	 * 年级EPQ维度分析报告图表加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 年级EPQ维度分析报告图表加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级EPQ维度分析报告图表数据", operationClassPath = "controller.SysEvaluationResultController.getgradeEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgradeepqstatischart")
	public String getgradeEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression expression = new Expression();
		JSONObject result = new JSONObject();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String gradeName = req.getParameter("gradename");
			String checktime = req.getParameter("checktime");

			if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
				expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (gradeName != null && !gradeName.equals("")) {
				expression.andEqu("gradeName", gradeName, String.class); // 添加schoolid的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}

			if (checktypeid.equals("1")) {
				List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVGradeEPQCheckReportStatisByCondition(expression.toString());

				// 用于柱状图数据存储的实体类
				// DEchartBingData edata = new DEchartBingData();

				// 构建柱状图数据
				List<String> categories = new ArrayList<String>();
				List<BingValues> values = new ArrayList<BingValues>();

				for (int i = 0; i < reportList.size(); i++) {
					VGradeEPQCheckReportStatis obj = (VGradeEPQCheckReportStatis) reportList.get(i);
					String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
							+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
					categories.add(catename);
					BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
					values.add(bingValues);
				}
				// 添加饼状图中分类的数据列表
				// edata.setCategories(categories);
				// 添加柱状图中分类数值的数据列表
				// edata.setValues(values);

				JSONArray jsonArray1 = JSONArray.fromObject(categories);
				result.put("categories", jsonArray1);
				JSONArray jsonArray2 = JSONArray.fromObject(values);
				result.put("values", jsonArray2);

			} else {
				List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
						.getVGradeEPQCheckReportStatisByCondition(expression.toString());

				// 用于柱状图数据存储的实体类
				// DEchartBingData edata = new DEchartBingData();

				// 构建柱状图数据
				List<String> categories = new ArrayList<String>();
				List<BingValues> values = new ArrayList<BingValues>();

				for (int i = 0; i < reportList.size(); i++) {
					VGradeEPQCheckReportStatis obj = (VGradeEPQCheckReportStatis) reportList.get(i);
					String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
							+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
					categories.add(catename);
					BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
					values.add(bingValues);
				}
				// 添加饼状图中分类的数据列表
				// edata.setCategories(categories);
				// 添加柱状图中分类数值的数据列表
				// edata.setValues(values);
				JSONArray jsonArray1 = JSONArray.fromObject(categories);
				result.put("categories", jsonArray1);
				JSONArray jsonArray2 = JSONArray.fromObject(values);
				result.put("values", jsonArray2);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}

	// TODO 2018-11-10 22:02 基于学校
	/**
	 * 学校测评统计分析报告查询控制类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 学校测评统计分析报告查询控制类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校测评统计分析报告", operationClassPath = "controller.SysEvaluationResultController.getSchoolEvaResultDetail(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getschoolevaresult")
	public String getSchoolEvaResultDetail(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression exp = new Expression();

		try {
			String reporttype = req.getParameter("reporttype");
			String checktime = req.getParameter("checktime");
			String schoolid = req.getParameter("schoolid");

			String currentPage = req.getParameter("page");
			String pageSize = req.getParameter("limit");

			if (currentPage != null && pageSize != null) {
				if (schoolid != null && !schoolid.equals("")) {
					exp.andEqu("schoolid", schoolid, String.class); // 添加schoolid的查询条件
				}
				if (reporttype != null && !reporttype.equals("")) {
					exp.andLike("checkname", reporttype, String.class);
				}

				if (checktime != null && !checktime.equals("")) {
					String[] checktimes = checktime.split("/");
					String starttime = checktimes[0];
					String endtime = checktimes[1];
					exp.andBetween("checktime", starttime, String.class);
					exp.andAnd(endtime, String.class);
				}
				exp.orderByAsc("checktime");

				String strwhere = exp.toString();
				List<VSchoolCheckReport> listsize = DAOFactory.getCheckReportDAO()
						.getSchoolCheckReportByStrwhere(strwhere);
				List<VSchoolCheckReport> reportList = DAOFactory.getCheckReportDAO().getSchoolCheckReportByStrwhere(
						strwhere, Integer.parseInt(currentPage), Integer.parseInt(pageSize));
				if (reportList != null && reportList.size() > 0) {
					result.put("code", 0);
					result.put("msg", "学校测评统计分析报告查询成功");
					result.put("count", listsize.size());
					JSONArray jsonArray = JSONArray.fromObject(reportList);
					result.element("data", jsonArray);
				} else {
					result.put("code", 1);
					result.put("msg", "无查询结果");
				}
			} else {
				result.put("code", 1);
				result.put("msg", "无查询结果");
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "学校测评统计分析报告查询失败");
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;

	}

	/**
	 * 学校测评统计分析报告，MHT维度分析，表格数据
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author djf
	 */
	// TODO 学校测评统计分析报告，MHT维度分析，表格数据
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校测评统计分析报告，MHT维度分析表格数据", operationClassPath = "controller.SysEvaluationResultController.getSchoolCheckStatisByItem(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getschoolcheckstatisbyitem")
	public String getSchoolCheckStatisByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();
		Expression expression = new Expression();
		PrintWriter out = resp.getWriter();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String checktime = req.getParameter("checktime");
			String schoolid = req.getParameter("schoolid");

			if (checktypeid != null && !checktypeid.equals("")) {
				expression.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
			}
			if (schoolid != null && !schoolid.equals("")) {
				expression.andEqu("schoolid", schoolid, String.class);
			}
			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) {
					List<VSchoolMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVSchoolMHTCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {
						result.put("code", 0);
						result.put("msg", "学校MHT测评统计分析查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}

				} else {
					List<VSchoolMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVSchoolMHTCheckReportStatisByCondition(expression.toString());
					if (reportList.size() > 0) {
						result.put("code", 0);
						result.put("msg", "学校MHT测评统计分析查询成功");
						result.put("count", reportList.size());
						JSONArray jsonArray = JSONArray.fromObject(reportList);
						result.element("data", jsonArray);
					} else {
						result.put("code", 1);
						result.put("msg", "无查询结果");
					}
				}
			} else {
				result.put("code", 1);
				result.put("msg", "无查询结果");
			}
		} catch (Exception e) {
			e.printStackTrace();
			result.put("code", 2);
			result.put("msg", "学校MHT测评统计分析查询失败");
		}
		out.println(result);
		return null;
	}

	/**
	 * 学校测评统计分析报告，MHT维度分析，饼图表
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author djf
	 */
	// TODO 学校测评统计分析报告，MHT维度分析，饼图表
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校测评统计分析报告，MHT维度分析饼图数据", operationClassPath = "controller.SysEvaluationResultController.getSchoolCheckStatisByItemBing(Model model,HttpServletRequest req,HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getschoolcheckstatisbyitembing")
	public String getSchoolCheckStatisByItemBing(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression exp = new Expression();

		try {
			String checktypeid = req.getParameter("checktypeid");
			String itemname = req.getParameter("itemname");
			String checktime = req.getParameter("checktime");
			String schoolid = req.getParameter("schoolid");

			if (checktypeid != null && !checktypeid.equals("")) {
				exp.andEqu("checktypeid", Integer.parseInt(checktypeid), Integer.class); // 添加schooltype的查询条件
			}
			if (itemname != null && itemname.trim().length() > 0) {
				exp.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
			}
			if (checktime != null && !checktime.equals("")) {
				exp.andEqu("checktime", checktime, String.class); // 添加schoolid的查询条件
			}
			if (schoolid != null && !schoolid.equals("")) {
				exp.andEqu("schoolid", schoolid, String.class);
			}

			if (checktypeid != null && !checktypeid.equals("")) {
				if (Integer.parseInt(checktypeid) == 1) {
					List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVSchoolEPQCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VSchoolEPQCheckReportStatis obj = (VSchoolEPQCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					out.close();
					return null;
				} else {
					List<VSchoolMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
							.getVSchoolMHTCheckReportStatisByCondition(exp.toString());

					// 用于柱状图数据存储的实体类
					DEchartBingData edata = new DEchartBingData();

					// 构建柱状图数据
					List<String> categories = new ArrayList<String>();
					List<BingValues> values = new ArrayList<BingValues>();

					for (int i = 0; i < reportList.size(); i++) {
						VSchoolMHTCheckReportStatis obj = (VSchoolMHTCheckReportStatis) reportList.get(i);
						String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
								+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
						categories.add(catename);
						BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
						values.add(bingValues);
					}
					// 添加饼状图中分类的数据列表
					edata.setCategories(categories);
					// 添加柱状图中分类数值的数据列表
					edata.setValues(values);

					PrintWriter out = resp.getWriter();
					out.write(JSON.toJSONString(edata));
					return null;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	/**
	 * 学校EPQ维度分析报告表格加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @size 2018-11-09 22:07
	 * @author 徐震霖
	 */
	// TODO 学校EPQ维度分析报告表格加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校EPQ维度分析报告表格数据", operationClassPath = "controller.SysEvaluationResultController.getSchoolEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getschoolepqstatistable")
	public String getSchoolEPQStatisTable(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		JSONObject result = new JSONObject();

		String checktypeid = req.getParameter("checktypeid");
		String itemname = req.getParameter("itemname");
		String schoolid = req.getParameter("schoolid");
		String checktime = req.getParameter("checktime");

		Expression expression = new Expression();
		if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
			expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
		}
		if (itemname != null && itemname.trim().length() > 0) {
			expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
		}
		if (schoolid != null && !schoolid.equals("")) {
			expression.andEqu("schoolid", schoolid, String.class); // 添加schoolid的查询条件
		}
		if (checktime != null && !checktime.equals("")) {
			expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
		}
		// System.out.println(expression.toString());
		if (checktypeid.equals("1")) {
			List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolEPQCheckReportStatisByCondition(expression.toString());
			if (reportList.size() > 0) {
				result.put("code", 0);
				result.put("msg", "查询成功");
				result.put("count", reportList.size());
				JSONArray jsonArray = JSONArray.fromObject(reportList);
				result.element("data", jsonArray);
				/*
				 * resjson.code = ResponseJSON.FLAG_SUCC; resjson.msg =
				 * "查询出"+reportList.size()+"条记录"; String json =
				 * JSON.toJSONString(reportList); String result =
				 * "{\"Rows\":"+json+",\"Total\":"+reportList.size()+"}";
				 * resjson.data = result;
				 */
			} else {
				result.put("code", 1);
				result.put("msg", "没有符合查询条件的记录");
				/*
				 * resjson.code = ResponseJSON.FLAG_FAIL; resjson.msg =
				 * "没有符合查询条件的记录";
				 */
			}
		} else {
			List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolEPQCheckReportStatisByCondition(expression.toString());
			if (reportList.size() > 0) {
				result.put("code", 0);
				result.put("msg", "查询成功");
				result.put("count", reportList.size());
				JSONArray jsonArray = JSONArray.fromObject(reportList);
				result.element("data", jsonArray);
				/*
				 * resjson.code = ResponseJSON.FLAG_SUCC; resjson.msg =
				 * "查询出"+reportList.size()+"条记录"; String json =
				 * JSON.toJSONString(reportList); String result =
				 * "{\"Rows\":"+json+",\"Total\":"+reportList.size()+"}";
				 * resjson.data = result;
				 */
			} else {
				result.put("code", 1);
				result.put("msg", "没有符合查询条件的记录");
				/*
				 * resjson.code = ResponseJSON.FLAG_FAIL; resjson.msg =
				 * "没有符合查询条件的记录";
				 */
			}
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;

		/*
		 * resp.setCharacterEncoding("utf-8");
		 * resp.setContentType("application/json"); PrintWriter out =
		 * resp.getWriter(); out.write(JSON.toJSONString(resjson)); out.close();
		 * return null;
		 */
	}

	/**
	 * 学校EPQ维度分析报告图表加载处理类
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 */
	// TODO 学校EPQ维度分析报告图表加载处理类
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校EPQ维度分析报告图表数据", operationClassPath = "controller.SysEvaluationResultController.getschoolEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getschoolepqstatischart")
	public String getschoolEPQStatisChart(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression expression = new Expression();
		JSONObject result = new JSONObject();

		String checktypeid = req.getParameter("checktypeid");
		String itemname = req.getParameter("itemname");
		String schoolid = req.getParameter("schoolid");
		String checktime = req.getParameter("checktime");

		if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
			expression.andEqu("checktypeid", checktypeid, Integer.class); // 添加schooltype的查询条件
		}
		if (itemname != null && itemname.trim().length() > 0) {
			expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
		}
		if (schoolid != null && !schoolid.equals("")) {
			expression.andEqu("schoolid", schoolid, String.class); // 添加schoolid的查询条件
		}
		if (checktime != null && !checktime.equals("")) {
			expression.andEqu("checktime", "" + checktime, String.class); // 添加schoolid的查询条件
		}

		if (checktypeid.equals("1")) {
			// System.out.println(expression.toString());
			List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolEPQCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			// DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VSchoolEPQCheckReportStatis obj = (VSchoolEPQCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}
			// 添加饼状图中分类的数据列表
			// edata.setCategories(categories);
			// 添加柱状图中分类数值的数据列表
			// edata.setValues(values);

			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);

		} else {
			// System.out.println(expression.toString());
			List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolEPQCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			//DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VSchoolEPQCheckReportStatis obj = (VSchoolEPQCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}
			// 添加饼状图中分类的数据列表
			// edata.setCategories(categories);
			// 添加柱状图中分类数值的数据列表
			// edata.setValues(values);
			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);
		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}

	/**
	 * 年级学生心理测评单项分布统计图表
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author 徐震霖
	 * @since 2018-11-10 20:58
	 */
	// TODO 年级学生心理测评单项分布统计图表
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询年级学生心理测评单项分布统计图表数据", operationClassPath = "controller.SysEvaluationResultController.getGetGradeEPQStatisChartByItem(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/年级测评统计分析报告")
	@RequestMapping(value = "/getgetgradeepqstatischartbyitem")
	public String getGetGradeEPQStatisChartByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression expression = new Expression();
		JSONObject result = new JSONObject();

		String checktypeid = req.getParameter("checktypeid");
		String itemname = req.getParameter("itemname");
		String gradeName = req.getParameter("gradename");
		String checktime = req.getParameter("checktime");

		if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
			expression.andEqu("checktypeid", "" + checktypeid, Integer.class); // 添加schooltype的查询条件
		}
		if (itemname != null && itemname.trim().length() > 0) {
			expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
		}
		if (checktime != null && !checktime.equals("")) {
			expression.andEqu("checktime", checktime, String.class); // 添加schoolid的查询条件
		}
		if (gradeName != null && !gradeName.equals("")) {
			expression.andEqu("gradename", gradeName, String.class);
		}

		if (checktypeid.equals("1")) {
			// System.out.println(expression.toString());
			List<VGradeEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVGradeEPQCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			//DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VGradeEPQCheckReportStatis obj = (VGradeEPQCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}

			// 添加饼状图中分类的数据列表
			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			// 添加柱状图中分类数值的数据列表
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);

		} else {
			// System.out.println(expression.toString());
			List<VGradeMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVGradeMHTCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			//DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VGradeMHTCheckReportStatis obj = (VGradeMHTCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}

			// 添加饼状图中分类的数据列表
			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			// 添加柱状图中分类数值的数据列表
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);

		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}

	/**
	 * 学校学生心理测评单项分布统计图表
	 * 
	 * @param model
	 * @param req
	 * @param resp
	 * @return
	 * @throws IOException
	 * @author 徐震霖
	 * @since 2018-11-10 20:58
	 */
	// TODO 学校学生心理测评单项分布统计图表
	@Log(operationType = Constant.OPERTATION_QUERY, operationDescribe = "查询学校学生心理测评单项分布统计图表数据", operationClassPath = "controller.SysEvaluationResultController.getGetSchoolEPQStatisChartByItem(Model model, HttpServletRequest req, HttpServletResponse resp)", operationMenu = "测评结果分析管理/学校测评统计分析报告")
	@RequestMapping(value = "/getgetschoolepqstatischartbyitem")
	public String getGetSchoolEPQStatisChartByItem(Model model, HttpServletRequest req, HttpServletResponse resp)
			throws IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("application/json");

		Expression expression = new Expression();
		JSONObject result = new JSONObject();

		String checktypeid = req.getParameter("checktypeid");
		String itemname = req.getParameter("itemname");
		String schoolname = req.getParameter("schoolname");
		String checktime = req.getParameter("checktime");

		if (checktypeid != null && !checktypeid.equals("") && !checktypeid.equals("0")) {
			expression.andEqu("checktypeid", "" + checktypeid, Integer.class); // 添加schooltype的查询条件
		}
		if (itemname != null && itemname.trim().length() > 0) {
			expression.andEqu("itemname", itemname, String.class); // 添加schooltype的查询条件
		}
		if (checktime != null && !checktime.equals("")) {
			expression.andEqu("checktime", checktime, String.class); // 添加schoolid的查询条件
		}
		if (schoolname != null && !schoolname.equals("")) {
			expression.andEqu("schoolname", schoolname, String.class);
		}

		if (checktypeid.equals("1")) {
			// System.out.println(expression.toString());
			List<VSchoolEPQCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolEPQCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			//DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VSchoolEPQCheckReportStatis obj = (VSchoolEPQCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}

			// 添加饼状图中分类的数据列表
			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			// 添加柱状图中分类数值的数据列表
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);

		} else {
			// System.out.println(expression.toString());
			List<VSchoolMHTCheckReportStatis> reportList = DAOFactory.getCheckStatisDAO()
					.getVSchoolMHTCheckReportStatisByCondition(expression.toString());

			// 用于柱状图数据存储的实体类
			//DEchartBingData edata = new DEchartBingData();

			// 构建柱状图数据
			List<String> categories = new ArrayList<String>();
			List<BingValues> values = new ArrayList<BingValues>();

			for (int i = 0; i < reportList.size(); i++) {
				VSchoolMHTCheckReportStatis obj = (VSchoolMHTCheckReportStatis) reportList.get(i);
				String catename = obj.getStatus().trim() + ":" + obj.getPersoncounter() + "("
						+ NumberUtil.tranRate(obj.getRate() * 100) + "%)";
				categories.add(catename);
				BingValues bingValues = new BingValues(obj.getPersoncounter(), catename);
				values.add(bingValues);
			}

			// 添加饼状图中分类的数据列表
			JSONArray jsonArray1 = JSONArray.fromObject(categories);
			result.put("categories", jsonArray1);
			// 添加柱状图中分类数值的数据列表
			JSONArray jsonArray2 = JSONArray.fromObject(values);
			result.put("values", jsonArray2);

		}

		PrintWriter out = resp.getWriter();
		out.println(result);
		return null;
	}
}
